package com.lin.statistics.schedule;

import com.lin.statistics.service.DailyService;
import com.lin.statistics.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class ScheduledTask {
    @Autowired
    private DailyService dailyService;

    // 在每天凌晨一点，把前一天的数据查询并做添加
    @Scheduled(cron = "0 0 1 * * ?")
    public void task(){
        dailyService.registerCount(DateUtil.formatDate(DateUtil.addDays(new Date(),-1)));
    }
}
